package com.woniuxy.common;

import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

@Component
public class RedisKey {
    /**
     * 登录
     * @param phone
     * @return
     */
    public static String getSendlogCodeKey(Long phone) {
        return "sendcode:log:phone:"+phone;
    }

    /**
     * 存储一分钟登录验证码
     * @param phone
     * @return
     */
    public static String getSendlogCodeInMinKey(String phone) {
        return "sendcode:log:min:phone"+phone;
    }

    /**
     * 存储一小时登录验证码
     * @param phone
     * @return
     */
    public static String getSendlogCodeInHourKey(String phone) {
        return "sendcode:log:hour:phone"+phone;
    }

    /**
     * 保存输入密码次数
     * @param email
     * @return
     */
    public static String pwdCount(String email) {
        return "pwd:phone"+email;
    }

    /**
     * 记录商家所有菜品的最外层键
     * @param storeId
     * @return
     */
    public static String getStoreFoods(String storeId) {
        return "foods:store:"+storeId;
    }
    /**
     * 记录商家所有菜品的小键
     * @param foodId
     * @return
     */
    public static String getFoodInfoByFoodId(String foodId) {
        return "foodId:"+foodId;
    }

    /**
     * 记录商家当日的营业额以及订单数量
     */
    public static String getStoreTurnoverKey(Long storeId) {
        return "storeturnover:"+"storeid:"+storeId;
    }

    /**
     *所有食品类型
     * @return
     */
    public static String getFoodTypeTreeKey() {
        return "food:foodtype:tree";
    }


    /**
     * 每个商铺的上月的总销量
     */
    public static String getStoreSaleKey(){
        LocalDate localDate = LocalDate.now();
        String dateStr = localDate.format(DateTimeFormatter.ofPattern("yyyy年MM月"));

        return "storesale:month:"+ dateStr;
    }

    /**
     * 商铺中每种食品的当月销量（只存当月的）
     */
    public static String getFoodSaleKey(){
        LocalDate localDate = LocalDate.now();
        String dateStr = localDate.format(DateTimeFormatter.ofPattern("yyyy年MM月"));
        return "foodsale:month:"+dateStr;
    }



}
